 <meta charset="utf-8">
 <div class="box" id="biz_authPermission_assign_conatainer" style="height: 700px;overflow-y: scroll;">
            <div class="box-header with-border">
               <form id="searchForm" role="form" class="form-inline">
                    <div class="form-group">
                         <label>权限名称</label>
                         <input name="name"  v-model="searchForm.name"  v-bind:value="searchForm.name"  type="text" placeholder="" class="form-control input-sm">
                    </div>
                    <div class="form-group">
                    <label>权限代码</label>
                         <input id="permCode" v-model="searchForm.permCode"  name="permCode" type="text" placeholder="" class="form-control input-sm">
                    </div>
                    
                   <div class="form-group" >
					 <label>所属应用</label>
						 <select id="appKey" name="appKey" v-model="searchForm.appKey"   
						    v-kselect="{url:'auth/authApp/loadAuthAppComboboVo',vmodel:'searchForm.appKey',firstEmpty:'false'}" class=" form-control"> </select>
					</div>
				
					 <div class="form-group" >
					 <label>所属模块</label>
						 <select id="moduleId"  name="moduleId" v-model="searchForm.moduleId" 
						    v-kselect="{url:'auth/authModule/loadModuleComboboVo',vmodel:'searchForm.moduleId',linkToDomId:'appKey',ajaxParamKey:'appKey',firstEmpty:'true'}" class=" form-control"> </select>
					</div>  
              
                  <button type="button"  class="btn btn-info pull-right m-t-n-xs" v-kperms="{perm:''}" v-on:click="search"><strong>查询</strong></button>
                </form>
            </div>
 <div class="box-body">
 	                       <div class="btn-group " id="authPermTableToolbar" role="group">
 	                       			<button type="button" v-kperms="{perm:''}"  class="btn btn-default" v-on:click="addPermsToRole">
                                        <i class="glyphicon glyphicon-plus" aria-hidden="true"></i> 添加
                                    </button>
                                  
                                    <button type="button"  v-kperms="{perm:''}" class="btn btn-default" v-on:click="removePermsFromRole">
                                        <i class="glyphicon glyphicon-trash" aria-hidden="true"></i> 移除
                                    </button>
                           </div>
           <table id="ahthPermBootstrapTable" data-mobile-responsive="true" ></table>
 </div>

<script>
var newa=new Vue({  
	  el: '#biz_authPermission_assign_conatainer', 
	  data:{
		  	searchForm:{
		  		isInRole: true,
		  		permCode: undefined,
		  		appKey: undefined,
		  		moduleId: undefined,
		  		roleId: undefined
		  	},
	    	bus:new Vue()
	  },
	  mounted:function(){
		 let _this=this;
		 _this.bus.$once(zfesVueDirective.getKselectOnInitEventName("appKey"), function (msg) {
			 let param=zfesLayerEditDg.getLayerParam();//roleId
			 _this.searchForm.roleId=param.roleId;
			 _this.initTable();
		 });
	  },
    methods: {
  	  initTable:function(){
  		
  		 let columns=[
  				{checkbox:true},
				{field:'permCode',title:'权限编码',width:160,sortable:true},
				{field:'name',title:'权限名称',width:160},
				{field:'enabled',title:'是否启用',width:60,formatter:zfesUtil.formatEnabled},
				{field:'moduleName',title:'所属模块',width:100},
				{field:'appName',title:'所属应用',width:80}];
  		  let url="auth/authRole/loadPermDataSetForRoleAssign";
    	  zfesBstable.vueLoadTable($("#ahthPermBootstrapTable"),$("#authPermTableToolbar"),url,columns,this.searchForm);
  	  },
  	  
  	  search:function(){
  		  zfesBstable.reload($("#ahthPermBootstrapTable")); 
  	  },
  	  refresh:function(){
  		  zfesBstable.refresh($("#ahthPermBootstrapTable"));
  	  },
  	removePermsFromRole: function(){
  	 	 if(zfesBstable.isSelectedRow($("#ahthPermBootstrapTable"))){
			  let ids=zfesBstable.getRowIds($("#ahthPermBootstrapTable"));
			  let　_this=this;
				 alertSwal.confirm("移除该权限","是否执行该操作",function(){
					    let ajaxUrl = "auth/authRole/removePermsFromRole";
					    zfesAjax.ajaxTodo(ajaxUrl, { "permIds" : ids,"roleId":_this.searchForm.roleId}, function(data) {
							alertSwal.successText(data.message);
							_this.refresh();
					});
		  		});
		  }
  	  },
  	addPermsToRole: function(){
  		let _this=this;
    	let url="/view/auth/authRole/authRole.prem.assign.lookback.html";
    	let param={roleId:_this.searchForm.roleId}
    	zfesLayerEditDg.lookback(url, param, "选择权限", 600, function() {
    		_this.refresh();
    	})
  	  }
   	
   }

});
</script>
 </div>

